#FROM centos:7
FROM python:3.9.6
#设置时区
ENV TZ "Asia/Shanghai"

# 设置系统环境变量DOCKER_SRC
ENV DOCKER_SRC=root_server
# 设置系统环境变量DOCKER_HOME
ENV DOCKER_HOME=/root
# 设置系统环境变量DOCKER_PROJECT
ENV DOCKER_PROJECT=/root/root_server

#这句指令相当与：cd /root
WORKDIR $DOCKER_HOME
#紧接着在root目录下面创建了两个文件夹
RUN mkdir media static

# 添加阿里云的源配置文件
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib" > /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >> /etc/apt/sources.list

# 更新并安装 JDK
# RUN apt-get update && \
#     apt-get install -y openjdk-8-jdk --no-install-recommends && \
#     rm -rf /var/lib/apt/lists/*

# ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# ENV PATH=$JAVA_HOME/bin:$PATH
# RUN apt-get install -y nginx
# RUN pip3 install --upgrade pip
# RUN pip3 install setuptools

# cd $DOCKER_PROJECT
WORKDIR $DOCKER_PROJECT
# . 表示当前目录，一是Dockerfile所在的目录，二是刚刚设置的DOCKER_PROJECT目录，
#这一步操作将会把项目中application目录下的所有文件拷贝到镜像目录DOCKER_PROJECT=/root/project下面
COPY ./ ./
#这一步安装python依赖软件django、Pillow、mysql-python、uwsgi、django-ckeditor。
#补充，-i 是修改pip源，默认的源速度很慢，经常卡在这里。
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
# RUN apt-get install -y cron
#暴露端口80，到时候执行docker run 的时候才好把宿主机端口映射到8000
EXPOSE 8000
RUN rm -rf 发布.txt
# 修改project为只读权限
RUN chmod -R 400 project
RUN chmod -R 400 apps
#赋予start_script执行权限
RUN chmod u+x start_script
#容器启动后要执行的命令
ENTRYPOINT ["./start_script"]